package com.lds.register.center.common.model.appinstance.request;

import com.lds.management.center.common.model.db.request.BaseCreateRequest;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 新建 - 请求
 *
 * @author lidongsheng
 * @since 2025-07-16
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Accessors(chain = true)
public class AppInstanceBaseCreateRequest extends BaseCreateRequest implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * IP
     */
    @NotBlank(message = "ip不能为空")
    private String ip;
    /**
     * 端口
     */
    @NotNull(message = "port不能为空")
    private Integer port;
    /**
     * 健康状态 1:健康 0:不健康
     */
    @NotNull(message = "healthy不能为空")
    private Boolean healthy;
    /**
     * 应用ID
     */
    @NotNull(message = "appId不能为空")
    private Long appId;
    /**
     * 权重
     */
    @NotNull(message = "weight不能为空")
    private Integer weight;
    /**
     * 启用状态 1:启用 2:停用
     */
    @NotNull(message = "enabled不能为空")
    private Boolean enabled;

    public void setIp(String ip) {
        this.ip = StringUtils.trimToNull(ip);
    }

}
